package buke;

public class D {
public static boolean istrue(int n){
	

	while(n!=0) {
	if(n%10==2) {
			return true;
		}
	n/=10;
	}
		return false;
}
	public static void main(String[] args) {
		int count =0;
	for(int i = 0;i<=2020;i++) {
		if(istrue(i)) {
			count++;
		}
		
	}
	System.out.println(count);
	}
	
}
